package com.linkhub.oms.admin.modules.user.accountflow.domain.vo;

import com.linkhub.oms.common.util.QtBigDecimalUtil;
import com.linkhub.oms.entity.UserAccountFlowEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * <p>
 * 用户资金流水VO
 * </p>
 *
 * @author Frank
 * @since 2024-05-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "UserAccountFlowVO", description = "用户资金流水VO")
@NoArgsConstructor
public class UserAccountFlowVO implements Serializable {

    @ApiModelProperty(value = "主键")
    private Long id;

    @ApiModelProperty(value = "用户id")
    private String merchantUserId;

    @ApiModelProperty(value = "用户名称")
    private String merchantUserName;

    @ApiModelProperty(value = "交易id")
    private String transactionId;

    @ApiModelProperty(value = "交易类型： 1-支出 2-收入 3-冻结 4-解冻 ")
    private Integer transactionType;

    @ApiModelProperty(value = "单据id")
    private String documentId;

    @ApiModelProperty(value = "单据类型： 1-提货单 2-订单 3-充值单 4-加工单 5-退货单")
    private Integer documentType;

    @ApiModelProperty(value = "费用类型： 1-提货费 2-仓储费 3-操作费 4-充值 5-运费 6-加工费 7-VAT手续费 8-VAT增值税 9-挂号费")
    private Integer expenseType;

    @ApiModelProperty(value = "金额")
    private String amount;

    @ApiModelProperty(value = "剩余金额")
    private String remainingBalance;

    @ApiModelProperty(value = "交易时间")
    private LocalDateTime createdTime;

    public UserAccountFlowVO(UserAccountFlowEntity userAccountFlowEntity) {
        this.id = userAccountFlowEntity.getId();
        this.merchantUserId = userAccountFlowEntity.getUserId();
        this.transactionId = userAccountFlowEntity.getTransactionId();
        this.transactionType = userAccountFlowEntity.getTransactionType().getCode();
        this.documentId = userAccountFlowEntity.getDocumentId();
        if (Objects.nonNull(userAccountFlowEntity.getDocumentType())) {
            this.documentType = userAccountFlowEntity.getDocumentType().getCode();
        }
        this.expenseType = userAccountFlowEntity.getExpenseType().getCode();
        this.amount = QtBigDecimalUtil.toString(userAccountFlowEntity.getAmount());
        this.remainingBalance = QtBigDecimalUtil.toString(userAccountFlowEntity.getRemainingBalance());
        this.createdTime = userAccountFlowEntity.getCreatedTime();
    }

}
